﻿
@{
    ViewBag.Title = "Algorithm";
}

<h2>Algorithm</h2>

<h3>Here's how a lunch is decided when the time comes</h3>
<ol>
    <li>
        A list of venues is created
    </li>
    <li class="text-left">
        All of the favorite venues (<span class="glyphicon glyphicon-ok text-success"></span>) for the lunchers are added, once per luncher.  For example, a venue liked by 3 lunchers would be added to the list three times.
    </li>
    <li>
        All venues that are disliked (<span class="glyphicon glyphicon-remove text-danger"></span>) by any luncher is removed from the list
    </li>
    <!--li>
        Any venue that is not disliked by any lunhcer is added once more to the list.  This includes venues given neutral preference by everyone (<span class="glyphicon glyphicon-minus"></span>), thus giving those venues a small chance of being picked. 
    </li-->
    <li>
        Qick venues are removed from the list, unless there are only quick venues available
    </li>
    <li>
        Venues that have been visited too recently (less than one week ago, by default) are removed
    </li>
    <li>
        Venues that have day-of-week restrictions are removed as necessary
    </li>
    <li>
        If at this point there are no possible venues, the user with the <b>most dislikes</b> is removed from consideration and the algorithm starts over at step 1.  This happens as necassary until there either venues available or there are no more users (in which case the lunch is aborted)
    </li>
    <li>
        If there is now only one possible venue, select it.  Otherwise:
    </li>
    <li>
        Pick the venues whose <i>genres</i> have been visited least-recently.  This helps ensure variety in genre.  Genres visited more than 2 weeks ago are all considered equally old.
    </li>
    <li>
        If there is only one possible venue, select it.  Otherwise:
    </li>
    <li>
        Pick the <i>venues</i> whose have been visited least-recently.  This helps ensure variety in venue.  Venues visited more than 2 weeks ago are all considered equally old.
    </li>
    <li>
        If there is only one possible venue, select it.  Otherwise:
    </li>
    <li>
        An entry from the remaining list is chosen at random.  Since there is one entry per like per venue, venues that are liked by more people are more likely to be selected.  However, there is still a chance for any venue that isn't disliked by anyone to be picked.
    </li>
    <h4>Special Conditions</h4>
    <li>
        If any users are removed in step 7, an alternate venue is chosen using the above algorithm considering only those users.  This ensures that there is an alternative venue picky users.
    </li>
    <li>
        If the chosen venue is not quick, a secondary venue is picked using the above algorithm but considering only quick venues.  This ensures that there is always a quick option.
    </li>
</ol>
<br />
<a href="@Url.Action("Index")" class="btn btn-default">Back to Home</a>